<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.log('parseInt');

        var a = '123';
        var ai = parseInt(a);
        console.log('a = ' + a + ', ai = ' + ai);

        var b = '123.456'; // 123
        var bi = parseInt(b);
        console.log('b = ' + b + ', bi = ' + bi);

        var c = '123abc.456'; // 123
        var ci = parseInt(c);
        console.log('c = ' + c + ', ci = ' + ci);

        var d = 'abc.456'; // NaN
        var di = parseInt(d);
        console.log('d = ' + d + ', di = ' + di);
    </script>


    <script>
        console.log('parseFloat');

        var a = '123';
        var ai = parseFloat(a);
        console.log('a = ' + a + ', ai = ' + ai);

        var b = '123.456000'; // 123
        var bi = parseFloat(b);
        console.log('b = ' + b + ', bi = ' + bi);

        var c = '123abc.456000'; // 123
        var ci = parseFloat(c);
        console.log('c = ' + c + ', ci = ' + ci);

        var d = 'abc.456000'; // NaN
        var di = parseFloat(d);
        console.log('d = ' + d + ', di = ' + di);
    </script>
</body>

</html>

<!-- JavaScript 标准内置对象 -->
<!-- https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects -->

<!-- parseInt -->
<!-- https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/parseInt -->

<!-- parseFloat -->
<!-- https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/parseFloat -->